package com.ymy.presto;

import java.sql.*;

/**
 * @author ymy.hadoop
 * @date 2019/5/16 上午11:51
 */
public class presto02 {

    public static void main(String[] args) throws Exception {

        Class.forName("com.facebook.presto.jdbc.PrestoDriver");
        Connection con = DriverManager.getConnection("jdbc:presto://cm01:8090/hive/default","hive",null);
        PreparedStatement ps = con.prepareStatement("select * from stu " +
                "where level='A' order by age");
        ResultSet set = ps.executeQuery();
        while(set.next()){
            int id = set.getInt("id");
            String name = set.getString("name");
            int age = set.getInt("age");
            String level = set.getString("level");

            System.out.println("id=" + id + "/n"
                    + "name=" + name
                    + "age=" + age
                    + "level=" + level);
        }


        ps.close();
        con.close();
    }
}
